<?php
@include ("includes/gpc_function.php");

$type       = isset($_GET["type"]) ? strtolower($_GET["type"])	 : "";
$id   		= isset($_GET["id"])  ?  	$_GET["id"]          	 : 0;
$cookie     = gpc_getCookieArray("imgtr");

switch($type)
{
	case "yahoo":
		CheckYahoo($id);
		break;
	case "skype":
		CheckSkype($id);
		break;
   case "wmsg":
        CheckWmsg($id);
        break;
   case 'spam':
        CreateSpamImg();
        break;
	default:
		echo "Not support!";
}

function CreateSpamImg()
{
    require("./includes/class_captcha.php");		 
    $aFonts = array('font/VeraSeBd.ttf');				 
    $oVisualCaptcha = new PhpCaptcha($aFonts, 140, 25);
    $oVisualCaptcha->UseColour(true);	 
    $oVisualCaptcha->Create();
}
function CheckYahoo($id)
{
    global $cookie;
	// seconds, minutes, hours, days
	$expires = 60*5*1*1;
	//header("Pragma: public");
	header("Cache-Control: maxage=".$expires);
	header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
	header("content-type: image/gif");
    header('ETag: "f4d030ef8f7ccb1:22665"');

    $iLastModf  = intval($cookie['ylm']);
    if($iLastModf<time()-$expires)
    {
        $link="http://opi.yahoo.com/online?u=".$id."&m=t";
        $data=file_get_contents($link);
        $cookie['ylm']=time();
    }else
    {
        if($cookie['yol']==1)
        {
            $data="";
        }else
        {
            $data="NOT ONLINE";
        }
    }
	//echo strlen($data);
	if(stripos($data,"NOT ONLINE")===false)
	{
	   $cookie['yol']=1;
	   $file="images/yahoo_on.gif";
	}else
	{
	   $cookie['yol']=0;
	   $file="images/yahoo_off.gif";
	}
    gpc_setCookieArray("imgtr",$cookie,0,0,"/Img/");
	echo file_get_contents($file);
}


function CheckSkype($id)
{
    global $cookie;
	// seconds, minutes, hours, days
	$expires = 60*5*1*1;

	//header("Pragma: public");
	header("Cache-Control: maxage=".$expires);
	header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
	header("content-type: image/gif");
    header('ETag: "f4d030ef8f7ccb1:22665"');

    $iLastModf  = intval($cookie['SK'.$id]);
    if($iLastModf<time()-$expires)
    {
        $link="http://mystatus.skype.com/smallclassic/".$id;
        $data=file_get_contents($link);
        $cookie['SK'.$id]=time();
    }else
    {
        if($cookie['sko'.$id]==1)
        {
            $data="";
        }else
        {
            $data="NOT ONLINE";
        }
    }

	if(strlen($data)>1000 || empty($data))
	{
	   $cookie['sko'.$id]=1;
		$file="images/skype_on.gif";
	}else
	{
	   $cookie['sko'.$id]=0;
		$file="images/skype_off.gif";
	}
    gpc_setCookieArray("imgtr",$cookie,0,0,"/Img/");
	echo file_get_contents($file);
}

function CheckWmsg($id)
{
    global $cookie;
	// seconds, minutes, hours, days
	$expires = 60*5*1*1;

	//header("Pragma: public");
	header("Cache-Control: maxage=".$expires);
	header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
	header("content-type: image/gif");
    header('ETag: "f4d030ef8f7ccb1:22665"');

   $file    = "images/wmsg.gif";
    
	echo file_get_contents($file);
}
?>
